#!/bin/bash

# opzioni errate
if ./bibaccess -a -p ; then
    exit 1
fi

# manca --loan o --query
if ./bibaccess ciccio.log ; then
    exit 1
fi

# mancano i file da elaborare
if ./bibaccess --loan ; then
    exit 1
fi

# opzioni incompatibili
if  ./bibaccess --loan gigi.log --query ; then
    exit 1
fi

# file non esistente
if ./bibaccess  __ciccio --loan ; then
    exit 1
fi

# chiamate corrette
LOGFILE="scuolanormalepi.log scuolasannapi.log regionetoscana.log"


for FILE in $LOGFILE ; do
    if ! ./bibaccess --query $FILE ; then
    exit 1
    fi
    if ! ./bibaccess $FILE --loan ; then
    exit 1
fi
done

LOGFILEq="scuolanormalepi.log --query scuolasannapi.log regionetoscana.log"
LOGFILEl="scuolanormalepi.log scuolasannapi.log --loan regionetoscana.log"
if ! ./bibaccess $LOGFILEq ; then
    exit 1
fi

if ! ./bibaccess $LOGFILEl ; then
    exit 1
fi

exit 0
